package o;

import android.content.Context;
import android.content.res.Configuration;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.ContextThemeWrapper;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.MeasureSpec;
import android.view.ViewGroup;
import androidx.appcompat.widget.ActionMenuPresenter;
import androidx.appcompat.widget.ActionMenuView;
import androidx.core.view.ViewCompat;
import o.ah.g;

public abstract class bu extends ViewGroup {
    private boolean ʻ;
    protected ic ʼ;
    protected ActionMenuPresenter ˊ;
    protected final Context ˋ;
    protected final c ˎ = new c(this);
    protected ActionMenuView ˏ;
    protected int ॱ;
    private boolean ॱॱ;

    protected class c implements ib {
        private boolean ˊ = false;
        int ˎ;
        final /* synthetic */ bu ॱ;

        protected c(bu buVar) {
            this.ॱ = buVar;
        }

        public c ˊ(ic icVar, int i) {
            this.ॱ.ʼ = icVar;
            this.ˎ = i;
            return this;
        }

        public void ˏ(View view) {
            super.setVisibility(0);
            this.ˊ = false;
        }

        public void ˎ(View view) {
            if (!this.ˊ) {
                this.ॱ.ʼ = null;
                super.setVisibility(this.ˎ);
            }
        }

        public void ˋ(View view) {
            this.ˊ = true;
        }
    }

    protected bu(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        TypedValue typedValue = new TypedValue();
        if (!context.getTheme().resolveAttribute(o.ah.c.ˏ, typedValue, true) || typedValue.resourceId == 0) {
            this.ˋ = context;
        } else {
            this.ˋ = new ContextThemeWrapper(context, typedValue.resourceId);
        }
    }

    protected void onConfigurationChanged(Configuration configuration) {
        super.onConfigurationChanged(configuration);
        TypedArray obtainStyledAttributes = getContext().obtainStyledAttributes(null, g.ˏ, o.ah.c.ॱ, 0);
        setContentHeight(obtainStyledAttributes.getLayoutDimension(g.ˋ, 0));
        obtainStyledAttributes.recycle();
        if (this.ˊ != null) {
            this.ˊ.ॱ(configuration);
        }
    }

    public boolean onTouchEvent(MotionEvent motionEvent) {
        int actionMasked = motionEvent.getActionMasked();
        if (actionMasked == 0) {
            this.ʻ = false;
        }
        if (!this.ʻ) {
            boolean onTouchEvent = super.onTouchEvent(motionEvent);
            if (actionMasked == 0 && !onTouchEvent) {
                this.ʻ = true;
            }
        }
        if (actionMasked == 1 || actionMasked == 3) {
            this.ʻ = false;
        }
        return true;
    }

    public boolean onHoverEvent(MotionEvent motionEvent) {
        int actionMasked = motionEvent.getActionMasked();
        if (actionMasked == 9) {
            this.ॱॱ = false;
        }
        if (!this.ॱॱ) {
            boolean onHoverEvent = super.onHoverEvent(motionEvent);
            if (actionMasked == 9 && !onHoverEvent) {
                this.ॱॱ = true;
            }
        }
        if (actionMasked == 10 || actionMasked == 3) {
            this.ॱॱ = false;
        }
        return true;
    }

    public void setContentHeight(int i) {
        this.ॱ = i;
        requestLayout();
    }

    public ic ˊ(int i, long j) {
        if (this.ʼ != null) {
            this.ʼ.ˏ();
        }
        if (i == 0) {
            if (getVisibility() != 0) {
                setAlpha(0.0f);
            }
            ic ˏ = ViewCompat.ˏॱ(this).ˏ(1.0f);
            ˏ.ˏ(j);
            ˏ.ॱ(this.ˎ.ˊ(ˏ, i));
            return ˏ;
        }
        ˏ = ViewCompat.ˏॱ(this).ˏ(0.0f);
        ˏ.ˏ(j);
        ˏ.ॱ(this.ˎ.ˊ(ˏ, i));
        return ˏ;
    }

    public void setVisibility(int i) {
        if (i != getVisibility()) {
            if (this.ʼ != null) {
                this.ʼ.ˏ();
            }
            super.setVisibility(i);
        }
    }

    public boolean ˎ() {
        if (this.ˊ != null) {
            return this.ˊ.ˎ();
        }
        return false;
    }

    protected int ˏ(View view, int i, int i2, int i3) {
        view.measure(MeasureSpec.makeMeasureSpec(i, Integer.MIN_VALUE), i2);
        return Math.max(0, (i - view.getMeasuredWidth()) - i3);
    }

    protected static int ˋ(int i, int i2, boolean z) {
        return z ? i - i2 : i + i2;
    }

    protected int ॱ(View view, int i, int i2, int i3, boolean z) {
        int measuredWidth = view.getMeasuredWidth();
        int measuredHeight = view.getMeasuredHeight();
        int i4 = ((i3 - measuredHeight) / 2) + i2;
        if (z) {
            view.layout(i - measuredWidth, i4, i, measuredHeight + i4);
        } else {
            view.layout(i, i4, i + measuredWidth, measuredHeight + i4);
        }
        return z ? -measuredWidth : measuredWidth;
    }
}
